/*
 * @author Javier A. Ramírez M.
 * jaramirez85@yahoo.es
 */
package com.jav;

import com.sun.lwuit.Button;
import com.sun.lwuit.Form;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;


public class Menu extends Form {
    
    private static final VentanaEspera waiting = new VentanaEspera("CARGANDO...");
    private static Form selector;

    public Menu (){
        super("CAPMOVIL");


        setLayout(new BoxLayout(BoxLayout.Y_AXIS));

        Button btSistema =  createButton("CARGUE ARCHIVOS",  1);
        addComponent(btSistema);

        Button btClientes =  createButton("CLIENTES",  2);
        addComponent(btClientes);

        Button btProductos =  createButton("PRODUCTOS",  4);
        addComponent(btProductos);

        Button btPedido =  createButton("EXPORTAR",  3);
        addComponent(btPedido);

        Button btReporte =  createButton("INFORMES",  5);
        addComponent(btReporte);

        Button btConfig =  createButton("CONFIGURACION",  6);
        addComponent(btConfig);

    }

    private Button createButton (String name, int accion){
        Button b = new Button(name);
        //b.getStyle().setMargin(3, 3, 5, 5);
        /*b.getStyle().setBgColor(0xFF8C00);
        b.getStyle().setFgColor(0x000000);
        b.getStyle().setBgSelectionColor(0x1ECF35);*/
        b.setAlignment(CENTER);
        b.addActionListener(new AccionForma(accion));
        return b;
    }


    class AccionForma implements ActionListener {

        private int selforma;

        public AccionForma(int forma) {
            this.selforma = forma;
        }

        public void actionPerformed(ActionEvent evt) {

            new Thread(new Runnable() {

                public void run() {
                        waiting.showModeless();
                        switch (selforma){
                            case 1:
                                selector= new CarArchivos();
                                break;
                            case 3:
                                selector = new ExportForm();
                                break;
                            case 2:
                                selector = ClienteForm.getInstance();
                                break;
                            case 4:
                                selector = new ProductosForm();
                                break;
                            case 5:
                                selector = new ReportForm();
                                break;
                            case 6:
                                selector = new SetupForm();
                                break;

                        }
                        waiting.dispose();
                        selector.show();                        

                }
              

            }).start();
        }   
    }
}


